<template>
  <!--功能配置-->
  <div class="search">
    <f-form ref="form4" form-key="sms">
      <f-form-item label="商品推荐功能" name="recommendEnable" type="switch" :value="GLOBAL_CONFIG.recommendEnable"/>
      <f-form-item label="商品参数" name="enableProductParams" type="switch" :value="GLOBAL_CONFIG.enableProductParams"/>
      <f-form-item label="商品分类级别" name="maxCategoryLevel" :value="GLOBAL_CONFIG.maxCategoryLevel"/>
      <f-form-item label="推荐奖励金额" type="number" name="recommendAmount" :value="GLOBAL_CONFIG.recommendAmount"/>
    </f-form>
  </div>
</template>

<script>
  export default {
    name: 'prodForm',
    props: {},
    data() {
      return {
        GLOBAL_CONFIG: {
          maxCategoryLevel: 3,
          recommendEnable: true,
          productParams:true,
          recommendAmount: 10
        }
      }
    },
    methods: {
      getOss() {
        this.http.get(this, {
          url: this.api.config.get,
          data: {
            configType: 'global'
          },
          success: function(me, data) {
            if (data.GLOBAL_CONFIG) {
              me.GLOBAL_CONFIG = JSON.parse(data.GLOBAL_CONFIG)
            }
          }
        })
      },
      setData() {
        this.$refs['form4'].resetFields()
        this.getOss()
      },
      handleSubmit() {
        this.$refs['form4'].getForm().validateFields((valid, values) => {
            if (!valid) {
              console.log(values)
              this.http.post(this, {
                url: this.api.config.globalConfigSave,
                data:values,
                success: function(me) {
                }
              })
            }
          }
        )
      }
    },
    computed: {
    },
    created() {
      this.getOss()
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
